﻿using System;

namespace System.Data
{
    // Token: 0x02000003 RID: 3
    public static class CacheManager
    {
        // Token: 0x06000003 RID: 3 RVA: 0x00002065 File Offset: 0x00000265
        public static void AddObject<TInput>(string key, TInput ob, int duration) where TInput : class
        {
            CacheManager._CacheService.Add(key, ob, duration);
        }

        // Token: 0x06000004 RID: 4 RVA: 0x0000207C File Offset: 0x0000027C
        public static void Update<TInput>(string key, TInput ob, int duration) where TInput : class
        {
            if (!string.IsNullOrEmpty(key))
            {
                if (CacheManager._CacheService.Contains(key))
                {
                    CacheManager._CacheService.Remove(key);
                    CacheManager.AddObject<TInput>(key, ob, duration);
                }
            }
        }

        // Token: 0x06000005 RID: 5 RVA: 0x000020C4 File Offset: 0x000002C4
        public static TResult GetObject<TResult>(string key) where TResult : class
        {
            TResult result;
            if (CacheManager._CacheService.Contains(key))
            {
                result = CacheManager._CacheService.Get<TResult>(key);
            }
            else
            {
                result = default(TResult);
            }
            return result;
        }

        // Token: 0x06000006 RID: 6 RVA: 0x00002100 File Offset: 0x00000300
        public static TResult GetCache<TResult>(string key, int duration, Func<TResult> func) where TResult : class
        {
            if (CacheManager._CacheService.Contains(key))
            {
                TResult tresult = CacheManager._CacheService.Get<TResult>(key);
                if (tresult != null)
                {
                    return tresult;
                }
            }
            TResult tresult2 = func();
            if (tresult2 != null)
            {
                CacheManager._CacheService.Add(key, tresult2, duration);
            }
            return tresult2;
        }

        // Token: 0x06000007 RID: 7 RVA: 0x00002170 File Offset: 0x00000370
        public static TResult GetCache<T1, TResult>(string key, int duration, Func<T1, TResult> func, T1 arg) where TResult : class
        {
            if (CacheManager._CacheService.Contains(key))
            {
                TResult tresult = CacheManager._CacheService.Get<TResult>(key);
                if (tresult != null)
                {
                    return tresult;
                }
            }
            TResult tresult2 = func(arg);
            if (tresult2 != null)
            {
                CacheManager._CacheService.Add(key, tresult2, duration);
            }
            return tresult2;
        }

        // Token: 0x06000008 RID: 8 RVA: 0x000021E0 File Offset: 0x000003E0
        public static TResult GetCache<T1, T2, TResult>(string key, int duration, Func<T1, T2, TResult> func, T1 arg1, T2 arg2) where TResult : class
        {
            if (CacheManager._CacheService.Contains(key))
            {
                TResult tresult = CacheManager._CacheService.Get<TResult>(key);
                if (tresult != null)
                {
                    return tresult;
                }
            }
            TResult tresult2 = func(arg1, arg2);
            if (tresult2 != null)
            {
                CacheManager._CacheService.Add(key, tresult2, duration);
            }
            return tresult2;
        }

        // Token: 0x06000009 RID: 9 RVA: 0x00002254 File Offset: 0x00000454
        public static TResult GetCache<T1, T2, T3, TResult>(string key, int duration, Func<T1, T2, T3, TResult> func, T1 arg1, T2 arg2, T3 arg3) where TResult : class
        {
            if (CacheManager._CacheService.Contains(key))
            {
                TResult tresult = CacheManager._CacheService.Get<TResult>(key);
                if (tresult != null)
                {
                    return tresult;
                }
            }
            TResult tresult2 = func(arg1, arg2, arg3);
            if (tresult2 != null)
            {
                CacheManager._CacheService.Add(key, tresult2, duration);
            }
            return tresult2;
        }

        // Token: 0x0600000A RID: 10 RVA: 0x000022C8 File Offset: 0x000004C8
        public static void Remove(string key)
        {
            if (!string.IsNullOrEmpty(key))
            {
                if (CacheManager._CacheService.Contains(key))
                {
                    CacheManager._CacheService.Remove(key);
                }
            }
        }

        // Token: 0x0600000B RID: 11 RVA: 0x00002306 File Offset: 0x00000506
        public static void ClearAll()
        {
            CacheManager._CacheService.ClearAll();
        }

        // Token: 0x0400000C RID: 12
        private static readonly ICache _CacheService = new NetCache();
    }
}
